#include <TimerOne.h>

#define INH_A  2
#define IN_A   3
#define INH_B  4
#define IN_B   5
#define INH_C  6
#define IN_C   7


const int INH[] = {INH_A, INH_B, INH_C};
const int IN[]  = {IN_A, IN_B, IN_C};


void setup() {
  for (int i=0; i<3; i++){
    pinMode(INH[i], OUTPUT);
    digitalWrite(INH[i], LOW);
  }
  for (int i=0; i<3; i++){
    pinMode(IN[i], OUTPUT);
    digitalWrite(IN[i], HIGH);
  }
  
  Timer1.initialize(10*1000);  //  us
//  Timer1.start();
  Serial.begin(9600);

//analogWrite(9, 128);
//  Timer1.pwm(9, 512);
}


int dutyCycle = 1; 
int dutyCycleMax = 10;
int lastDuty = dutyCycle;
void loop() {
  int t = millis() / 1000;
  dutyCycle = 1023 * (t % dutyCycleMax) / dutyCycleMax;  // increase dutyCycle every second

  if (dutyCycle != lastDuty){
    lastDuty = dutyCycle;
    Timer1.pwm(INH_A, dutyCycle);Timer1.pwm(IN_A, dutyCycle);
    Timer1.pwm(INH_B, dutyCycle);Timer1.pwm(IN_B, dutyCycle);
    Timer1.pwm(INH_C, dutyCycle);Timer1.pwm(IN_C, dutyCycle);
    Timer1.pwm(9, dutyCycle); Timer1.pwm(10, dutyCycle);

    Serial.print(t); Serial.print(", "); 
    Serial.print(t % dutyCycleMax); Serial.print(", ");
    Serial.println(dutyCycle);
  }

//  delay(500);
}
